﻿//代码即注释
#define _CRT_SECURE_NO_WARNINGS
#include "LinkedList.h"
#include "menu.h"
#include "fileManager.h"
#include "services.h"
#include <stdlib.h>
#include <process.h>
#include <windows.h>
HANDLE autoSaveService;
HANDLE consumptionService;
list* head = list_create();
list* last = head;
int main()
{
    readCard();
    autoSaveService = (HANDLE)_beginthread(AutoSave, 0, NULL);
    consumptionService = (HANDLE)_beginthread(consumption, 0, NULL);
    int option = 0;
    printf("欢迎进入计费管理系统\n");
    do {
        printf("\033c");
        printMenu();
        scanf_s("%d", &option);
        switch (option) {
            case 1: {
                add();
                break;
            }
            case 2: {
                query();
                break;
            }
            case 3: {
                startConsumption();
                break;
            }
            case 4: {
                endConsumption();
                break;
            }
            case 5: {
                charge();
                break;
            }
            case 6: {
                moneyBack();
                break;
            }
            case 7: {
                changePassword();
                break;
            }
            case 8: {
                cardCancel();
                break;
            }
            case 9: {
                queryAll();
                break;
            }
            case 0: {
                CloseHandle(autoSaveService);
                CloseHandle(consumptionService);
                Save();
                list_free(head);
                break;
            }
            default: {
                break;
            }
        }
        printf("按下回车以返回或退出");
        getchar();
        getchar();
    } while (option != 0);
}